package com.quantum.util
{
	import com.quantum.logging.LogFactory;

	import mx.logging.ILogger;


	/**
	 * Diagnostic utility methods useful in development and identifying issues in
	 * production code.
	 *
	 * <p>Typically, each of these could have different behaviors in debug and release builds.
	 * Please reference the method documentation for specifics on the differences.</p>
	 *
	 * <p>SDK Version 1.0.0</p>
	 */
	[SDK]
	public class Assert
	{
		private static var log:ILogger=LogFactory.getLogger(Assert);

		/**
		 * Asserts if the given condition is true. If not, then throws
		 * an <code>Error</code> using the given <code>message</code>.
		 *
		 * <p>Note: Asserts are triggered only in debug builds.</p>
		 */
		public static function assert(condition:Boolean, message:String):void
		{
			if (condition)
			{
				return;
			}

			var e:Error=new Error("Assertion failed: " + message);

			// Log the error stack trace.
			log.error(e.getStackTrace());

			throw e;
		}
	}

}